import {
	postData,
	getData,
	putData
} from "./net.js"

/// 登录
export const login = async (data) => {
	return await postData({
		path: "/user/login",
		data: data
	})
}

/// 注册
export const regist = async (data) => {
	return await postData({
		path: "/user/regist",
		data: data
	})
}

/// 修改密码
export const change_password = async (data) => {
	return await postData({
		path: "/user/change_password",
		data: data
	})
}

/// 添加、修改基本资料
export const save_profile = async (data) => {
	let {uid} = getApp().globalData;
	return await postData({
		path: "/profile/"+uid,
		data: data
	})
}

export const get_profile = async ()=>{
	let {uid} = getApp().globalData;
	return await getData({
		path: "/profile/"+uid,
	})
}

/// 压力检测分
export const stress_list = async () => {
	return await getData({
		path: "/stress"
	})
}

/// 提交压力检测
export const submit_stress_score = async (score_x, score_y, score_z) => {
	let {uid} = getApp().globalData;
	return await putData({
		path: `/score/${uid}`,
		data: {
			score_x,
			score_y,
			score_z
		}
	})
}

/// 肌肉力量
export const submit_muscle_score = async (score_muscle_ask) => {
	let {uid} = getApp().globalData;
	return await putData({
		path: `/score/${uid}`,
		data: {
			score_muscle_ask
		}
	})
}

/// 添加或者更新分数
export const add_update_score = async (data) => {
	let {uid} = getApp().globalData;
	return await putData({
		path: `/score/${uid}`,
		data: {
			...data
		}
	})
}

/// 获取操作记录
export const get_record = async () => {
	let {uid} = getApp().globalData;
	return await getData({
		path: `/record/${uid}`,
	})
}

/// 添加修改记录
export const add_update_record = async (data) => {
	let {uid} = getApp().globalData;
	return await postData({
		path: `/record/${uid}`,
		data: {
			...data
		}
	})
}

/// 获取分数
export const get_score = async () => {
	let {uid} = getApp().globalData;
	return await getData({
		path: `/score/${uid}`,
	})
}